package cn.ruituo.adv5;
import java.io.*;
import java.util.Scanner;

public class Encryption {
    public static void main(String[] args) {
        Scanner input = new Scanner(System.in);
        DataInputStream dis = null;
        DataOutputStream dos = null;
        File file = null;
        try {
            String fileName="E:\\temp\\java72\\advance\\1.txt";
            file = new File(fileName);
            dis = new DataInputStream(new FileInputStream(fileName));

            dos = new DataOutputStream(new FileOutputStream("E:\\temp\\java72\\advance\\2021-2.txt"));
            int s = 0;
            while ((s = dis.read()) != -1) {
                dos.write(~s);
            }
            dos.flush();
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (dos != null) {
                try {
                    dos.close();

                    System.out.println("原文件加密成功！");
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            if (dis != null) {
                try {
                    dis.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            file.delete();
        }
    }
}
